.class public final Lcom/burstly/lib/currency/CurrencyManager;
.super Ljava/lang/Object;
.source "CurrencyManager.java"

# interfaces
.implements Lcom/burstly/lib/feature/currency/ICurrencyManager;


# static fields
.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "CurrencyManager"

.field private static sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

.field private static volatile sIninialized:Z

.field private static sStorage:Lcom/burstly/lib/currency/UserAccountStorage;


# instance fields
.field private final mListeners:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Lcom/burstly/lib/feature/currency/ICurrencyListener;",
            ">;"
        }
    .end annotation
.end field

.field private final mRequester:Lcom/burstly/lib/currency/request/CurrencyRequester;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 46
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/currency/CurrencyManager;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-void
.end method

.method public constructor <init>()V
    .locals 2

    .prologue
    .line 41
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 71
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Lcom/burstly/lib/currency/CurrencyManager;->mListeners:Ljava/util/List;

    .line 76
    new-instance v0, Lcom/burstly/lib/currency/request/CurrencyRequester;

    iget-object v1, p0, Lcom/burstly/lib/currency/CurrencyManager;->mListeners:Ljava/util/List;

    invoke-direct {v0, v1}, Lcom/burstly/lib/currency/request/CurrencyRequester;-><init>(Ljava/util/List;)V

    iput-object v0, p0, Lcom/burstly/lib/currency/CurrencyManager;->mRequester:Lcom/burstly/lib/currency/request/CurrencyRequester;

    return-void
.end method

.method private changeBalance(Lcom/burstly/lib/currency/AccountInfo;ILjava/lang/String;Z)I
    .locals 8
    .parameter "info"
    .parameter "amount"
    .parameter "currency"
    .parameter "increase"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    const/4 v7, 0x1

    const/4 v2, 0x0

    .line 304
    invoke-direct {p0, p1}, Lcom/burstly/lib/currency/CurrencyManager;->checkAccountInfo(Lcom/burstly/lib/currency/AccountInfo;)V

    .line 305
    if-nez p3, :cond_0

    .line 306
    new-instance v2, Ljava/lang/IllegalArgumentException;

    const-string v3, "Currency name can not be null!"

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2

    .line 308
    :cond_0
    sget-object v3, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    invoke-virtual {v3, p1, v7}, Lcom/burstly/lib/currency/UserAccountStorage;->getAccount(Lcom/burstly/lib/currency/AccountInfo;Z)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 309
    .local v0, account:Lcom/burstly/lib/currency/UserAccount;
    if-eqz v0, :cond_2

    .line 310
    invoke-virtual {v0, p3}, Lcom/burstly/lib/currency/UserAccount;->getCurrencyAccount(Ljava/lang/String;)Lcom/burstly/lib/currency/UserCurrencyAccount;

    move-result-object v1

    .line 311
    .local v1, currencyAccount:Lcom/burstly/lib/currency/UserCurrencyAccount;
    if-nez v1, :cond_1

    .line 312
    sget-object v3, Lcom/burstly/lib/currency/CurrencyManager;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v4, "CurrencyManager"

    const-string v5, "\"{0}\" is not known to the user {1}. Created local currency."

    const/4 v6, 0x2

    new-array v6, v6, [Ljava/lang/Object;

    aput-object p3, v6, v2

    aput-object v0, v6, v7

    invoke-virtual {v3, v4, v5, v6}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 313
    new-instance v1, Lcom/burstly/lib/currency/UserCurrencyAccount;

    .end local v1           #currencyAccount:Lcom/burstly/lib/currency/UserCurrencyAccount;
    invoke-direct {v1, p3}, Lcom/burstly/lib/currency/UserCurrencyAccount;-><init>(Ljava/lang/String;)V

    .line 314
    .restart local v1       #currencyAccount:Lcom/burstly/lib/currency/UserCurrencyAccount;
    invoke-virtual {v0, p3, v1}, Lcom/burstly/lib/currency/UserAccount;->setCurrencyAccount(Ljava/lang/String;Lcom/burstly/lib/currency/UserCurrencyAccount;)V

    .line 316
    :cond_1
    invoke-virtual {v1}, Lcom/burstly/lib/currency/UserCurrencyAccount;->getActualBalance()I

    move-result v2

    invoke-virtual {v1, v2}, Lcom/burstly/lib/currency/UserCurrencyAccount;->setOldTotalCurrencyAmount(I)V

    .line 317
    if-eqz p4, :cond_3

    .line 318
    invoke-virtual {v1}, Lcom/burstly/lib/currency/UserCurrencyAccount;->getTotalIncomeAmount()I

    move-result v2

    add-int/2addr v2, p2

    invoke-virtual {v1, v2}, Lcom/burstly/lib/currency/UserCurrencyAccount;->setTotalIncomeAmount(I)V

    .line 322
    :goto_0
    sget-object v2, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    invoke-virtual {v2, v0}, Lcom/burstly/lib/currency/UserAccountStorage;->saveAccount(Lcom/burstly/lib/currency/UserAccount;)V

    .line 323
    invoke-static {v1}, Lcom/burstly/lib/currency/BalanceUpdateInfo;->createFrom(Lcom/burstly/lib/currency/UserCurrencyAccount;)Lcom/burstly/lib/currency/BalanceUpdateInfo;

    move-result-object v2

    invoke-direct {p0, v2}, Lcom/burstly/lib/currency/CurrencyManager;->notifyListeners(Lcom/burstly/lib/currency/BalanceUpdateInfo;)V

    .line 324
    invoke-virtual {v1}, Lcom/burstly/lib/currency/UserCurrencyAccount;->getActualBalance()I

    move-result v2

    .line 326
    .end local v1           #currencyAccount:Lcom/burstly/lib/currency/UserCurrencyAccount;
    :cond_2
    return v2

    .line 320
    .restart local v1       #currencyAccount:Lcom/burstly/lib/currency/UserCurrencyAccount;
    :cond_3
    invoke-virtual {v1}, Lcom/burstly/lib/currency/UserCurrencyAccount;->getTotalOutcomeAmount()I

    move-result v2

    add-int/2addr v2, p2

    invoke-virtual {v1, v2}, Lcom/burstly/lib/currency/UserCurrencyAccount;->setTotalOutcomeAmount(I)V

    goto :goto_0
.end method

.method private checkAccountInfo(Lcom/burstly/lib/currency/AccountInfo;)V
    .locals 2
    .parameter "info"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    .line 401
    const-string v0, "account info could not be null!"

    invoke-direct {p0, p1, v0}, Lcom/burstly/lib/currency/CurrencyManager;->checkNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 402
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getPubId()Ljava/lang/String;

    move-result-object v0

    const-string v1, "Publisher id is null"

    invoke-direct {p0, v0, v1}, Lcom/burstly/lib/currency/CurrencyManager;->checkNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 403
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getUserId()Ljava/lang/String;

    move-result-object v0

    const-string v1, "User id is null"

    invoke-direct {p0, v0, v1}, Lcom/burstly/lib/currency/CurrencyManager;->checkNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 404
    return-void
.end method

.method private checkForUpdate(Lcom/burstly/lib/currency/AccountInfo;)V
    .locals 5
    .parameter "info"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;,
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    .line 368
    invoke-static {}, Lcom/burstly/lib/network/request/RequestManager;->isOnline()Z

    move-result v1

    if-nez v1, :cond_0

    .line 369
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "CurrencyManager"

    const-string v3, "No network connection."

    const/4 v4, 0x0

    new-array v4, v4, [Ljava/lang/Object;

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 370
    new-instance v1, Ljava/io/IOException;

    const-string v2, "No network connection."

    invoke-direct {v1, v2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 372
    :cond_0
    invoke-direct {p0, p1}, Lcom/burstly/lib/currency/CurrencyManager;->checkAccountInfo(Lcom/burstly/lib/currency/AccountInfo;)V

    .line 373
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    const/4 v2, 0x1

    invoke-virtual {v1, p1, v2}, Lcom/burstly/lib/currency/UserAccountStorage;->getAccount(Lcom/burstly/lib/currency/AccountInfo;Z)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 374
    .local v0, account:Lcom/burstly/lib/currency/UserAccount;
    iget-object v1, p0, Lcom/burstly/lib/currency/CurrencyManager;->mRequester:Lcom/burstly/lib/currency/request/CurrencyRequester;

    invoke-virtual {v1, v0, p1}, Lcom/burstly/lib/currency/request/CurrencyRequester;->requestBalanceUpdate(Lcom/burstly/lib/currency/UserAccount;Lcom/burstly/lib/currency/AccountInfo;)V

    .line 375
    return-void
.end method

.method private checkInitialized()V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    .line 384
    sget-boolean v0, Lcom/burstly/lib/currency/CurrencyManager;->sIninialized:Z

    if-nez v0, :cond_0

    .line 385
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "CurrencyManager has noot been properly initialized yet! Call for initManager first."

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 388
    :cond_0
    return-void
.end method

.method private checkNotNull(Ljava/lang/Object;Ljava/lang/String;)V
    .locals 1
    .parameter "obj"
    .parameter "errorMessage"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    .line 414
    if-nez p1, :cond_0

    .line 415
    new-instance v0, Ljava/lang/IllegalArgumentException;

    invoke-direct {v0, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 417
    :cond_0
    return-void
.end method

.method private getBalance(Lcom/burstly/lib/currency/AccountInfo;Ljava/lang/String;)I
    .locals 8
    .parameter "accountInfo"
    .parameter "currency"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    const/4 v2, 0x0

    .line 191
    invoke-direct {p0, p1}, Lcom/burstly/lib/currency/CurrencyManager;->checkAccountInfo(Lcom/burstly/lib/currency/AccountInfo;)V

    .line 192
    if-nez p2, :cond_0

    .line 193
    new-instance v2, Ljava/lang/IllegalArgumentException;

    const-string v3, "Currency name can not be null!"

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2

    .line 195
    :cond_0
    sget-object v3, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    invoke-virtual {v3, p1, v2}, Lcom/burstly/lib/currency/UserAccountStorage;->getAccount(Lcom/burstly/lib/currency/AccountInfo;Z)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 196
    .local v0, account:Lcom/burstly/lib/currency/UserAccount;
    if-nez v0, :cond_1

    .line 204
    :goto_0
    return v2

    .line 199
    :cond_1
    invoke-virtual {v0, p2}, Lcom/burstly/lib/currency/UserAccount;->getCurrencyAccount(Ljava/lang/String;)Lcom/burstly/lib/currency/UserCurrencyAccount;

    move-result-object v1

    .line 200
    .local v1, currencyAccount:Lcom/burstly/lib/currency/UserCurrencyAccount;
    if-nez v1, :cond_2

    .line 201
    sget-object v3, Lcom/burstly/lib/currency/CurrencyManager;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v4, "CurrencyManager"

    const-string v5, "{0} is not known to the user {1}"

    const/4 v6, 0x2

    new-array v6, v6, [Ljava/lang/Object;

    aput-object p2, v6, v2

    const/4 v7, 0x1

    aput-object v0, v6, v7

    invoke-virtual {v3, v4, v5, v6}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0

    .line 204
    :cond_2
    invoke-virtual {v1}, Lcom/burstly/lib/currency/UserCurrencyAccount;->getActualBalance()I

    move-result v2

    goto :goto_0
.end method

.method private declared-synchronized internalInitManager(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
    .locals 5
    .parameter "context"
    .parameter "publisherId"
    .parameter "userId"

    .prologue
    .line 115
    monitor-enter p0

    :try_start_0
    sget-boolean v1, Lcom/burstly/lib/currency/CurrencyManager;->sIninialized:Z

    if-nez v1, :cond_0

    .line 116
    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->setApplicationContext(Landroid/content/Context;)V

    .line 117
    invoke-static {p1}, Lcom/burstly/lib/network/request/RequestManager;->initRquestManager(Landroid/content/Context;)V

    .line 118
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object v1

    invoke-static {v1}, Lcom/burstly/lib/currency/UserAccountStorage;->initCacheDirectory(Landroid/content/Context;)V

    .line 119
    invoke-static {}, Lcom/burstly/lib/currency/UserAccountStorage;->getInstance()Lcom/burstly/lib/currency/UserAccountStorage;

    move-result-object v1

    sput-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    .line 120
    invoke-static {p1}, Lcom/burstly/lib/BurstlySdk;->init(Landroid/content/Context;)V

    .line 121
    const/4 v1, 0x1

    sput-boolean v1, Lcom/burstly/lib/currency/CurrencyManager;->sIninialized:Z

    .line 123
    :cond_0
    if-eqz p3, :cond_1

    invoke-virtual {p3}, Ljava/lang/String;->length()I

    move-result v1

    if-nez v1, :cond_3

    .line 124
    :cond_1
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "CurrencyManager"

    const-string v3, "Using default user ID == device ID"

    const/4 v4, 0x0

    new-array v4, v4, [Ljava/lang/Object;

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 125
    new-instance v1, Lcom/burstly/lib/currency/AccountInfo;

    invoke-direct {v1, p2}, Lcom/burstly/lib/currency/AccountInfo;-><init>(Ljava/lang/String;)V

    sput-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    .line 130
    :goto_0
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    sget-object v2, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    const/4 v3, 0x1

    invoke-virtual {v1, v2, v3}, Lcom/burstly/lib/currency/UserAccountStorage;->getAccount(Lcom/burstly/lib/currency/AccountInfo;Z)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 131
    .local v0, userAccount:Lcom/burstly/lib/currency/UserAccount;
    invoke-virtual {v0}, Lcom/burstly/lib/currency/UserAccount;->isNew()Z

    move-result v1

    if-eqz v1, :cond_2

    .line 132
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    invoke-direct {p0, v1}, Lcom/burstly/lib/currency/CurrencyManager;->resetBalanceIfNeed(Lcom/burstly/lib/currency/AccountInfo;)V

    .line 133
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    invoke-virtual {v1, v0}, Lcom/burstly/lib/currency/UserAccountStorage;->saveAccount(Lcom/burstly/lib/currency/UserAccount;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 135
    :cond_2
    monitor-exit p0

    return-void

    .line 127
    .end local v0           #userAccount:Lcom/burstly/lib/currency/UserAccount;
    :cond_3
    :try_start_1
    new-instance v1, Lcom/burstly/lib/currency/AccountInfo;

    invoke-direct {v1, p2, p3}, Lcom/burstly/lib/currency/AccountInfo;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    sput-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 115
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method private notifyListeners(Lcom/burstly/lib/currency/BalanceUpdateInfo;)V
    .locals 4
    .parameter "balanceUpdateInfo"

    .prologue
    .line 335
    iget-object v3, p0, Lcom/burstly/lib/currency/CurrencyManager;->mListeners:Ljava/util/List;

    invoke-interface {v3}, Ljava/util/List;->isEmpty()Z

    move-result v3

    if-nez v3, :cond_0

    .line 336
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    .line 337
    .local v0, event:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Lcom/burstly/lib/currency/BalanceUpdateInfo;>;"
    invoke-virtual {p1}, Lcom/burstly/lib/currency/BalanceUpdateInfo;->getCurrency()Ljava/lang/String;

    move-result-object v3

    invoke-interface {v0, v3, p1}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 338
    iget-object v3, p0, Lcom/burstly/lib/currency/CurrencyManager;->mListeners:Ljava/util/List;

    invoke-interface {v3}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v1

    .local v1, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_0

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/burstly/lib/feature/currency/ICurrencyListener;

    .line 339
    .local v2, listener:Lcom/burstly/lib/feature/currency/ICurrencyListener;
    invoke-interface {v2, v0}, Lcom/burstly/lib/feature/currency/ICurrencyListener;->didUpdateBalance(Ljava/util/Map;)V

    goto :goto_0

    .line 342
    .end local v0           #event:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Lcom/burstly/lib/currency/BalanceUpdateInfo;>;"
    .end local v1           #i$:Ljava/util/Iterator;
    .end local v2           #listener:Lcom/burstly/lib/feature/currency/ICurrencyListener;
    :cond_0
    return-void
.end method

.method private resetBalance(Lcom/burstly/lib/currency/AccountInfo;)V
    .locals 3
    .parameter "accountInfo"

    .prologue
    .line 285
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    const/4 v2, 0x1

    invoke-virtual {v1, p1, v2}, Lcom/burstly/lib/currency/UserAccountStorage;->getAccount(Lcom/burstly/lib/currency/AccountInfo;Z)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 286
    .local v0, account:Lcom/burstly/lib/currency/UserAccount;
    invoke-virtual {v0}, Lcom/burstly/lib/currency/UserAccount;->isNew()Z

    move-result v1

    if-nez v1, :cond_0

    .line 287
    sget-object v1, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    invoke-virtual {v0}, Lcom/burstly/lib/currency/UserAccount;->getCacheFilename()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/burstly/lib/currency/UserAccountStorage;->clearStorage(Ljava/lang/String;)V

    .line 289
    :cond_0
    iget-object v1, p0, Lcom/burstly/lib/currency/CurrencyManager;->mRequester:Lcom/burstly/lib/currency/request/CurrencyRequester;

    invoke-virtual {v1, p1}, Lcom/burstly/lib/currency/request/CurrencyRequester;->requestBalanceReset(Lcom/burstly/lib/currency/AccountInfo;)V

    .line 290
    return-void
.end method

.method private resetBalanceIfNeed(Lcom/burstly/lib/currency/AccountInfo;)V
    .locals 2
    .parameter "accInfo"

    .prologue
    .line 273
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getUserId()Ljava/lang/String;

    move-result-object v0

    invoke-static {}, Lcom/burstly/lib/util/Utils;->getDeviceId()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 274
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    invoke-direct {p0, v0}, Lcom/burstly/lib/currency/CurrencyManager;->resetBalance(Lcom/burstly/lib/currency/AccountInfo;)V

    .line 276
    :cond_0
    return-void
.end method


# virtual methods
.method public addCurrencyListener(Lcom/burstly/lib/feature/currency/ICurrencyListener;)V
    .locals 1
    .parameter "listener"

    .prologue
    .line 144
    if-eqz p1, :cond_0

    .line 145
    iget-object v0, p0, Lcom/burstly/lib/currency/CurrencyManager;->mListeners:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 147
    :cond_0
    return-void
.end method

.method public backupFileNames()[Ljava/lang/String;
    .locals 1
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    .line 263
    invoke-direct {p0}, Lcom/burstly/lib/currency/CurrencyManager;->checkInitialized()V

    .line 264
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->sStorage:Lcom/burstly/lib/currency/UserAccountStorage;

    invoke-virtual {v0}, Lcom/burstly/lib/currency/UserAccountStorage;->getCachedFileList()[Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public checkForUpdate()V
    .locals 1
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;,
            Ljava/lang/IllegalArgumentException;,
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    .line 356
    invoke-direct {p0}, Lcom/burstly/lib/currency/CurrencyManager;->checkInitialized()V

    .line 357
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    invoke-direct {p0, v0}, Lcom/burstly/lib/currency/CurrencyManager;->checkForUpdate(Lcom/burstly/lib/currency/AccountInfo;)V

    .line 358
    return-void
.end method

.method public decreaseBalance(ILjava/lang/String;)I
    .locals 2
    .parameter "amount"
    .parameter "currency"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;,
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    .line 249
    invoke-direct {p0}, Lcom/burstly/lib/currency/CurrencyManager;->checkInitialized()V

    .line 250
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    const/4 v1, 0x0

    invoke-direct {p0, v0, p1, p2, v1}, Lcom/burstly/lib/currency/CurrencyManager;->changeBalance(Lcom/burstly/lib/currency/AccountInfo;ILjava/lang/String;Z)I

    move-result v0

    return v0
.end method

.method public getBalance(Ljava/lang/String;)I
    .locals 1
    .parameter "currency"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;,
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    .line 217
    invoke-direct {p0}, Lcom/burstly/lib/currency/CurrencyManager;->checkInitialized()V

    .line 218
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    invoke-direct {p0, v0, p1}, Lcom/burstly/lib/currency/CurrencyManager;->getBalance(Lcom/burstly/lib/currency/AccountInfo;Ljava/lang/String;)I

    move-result v0

    return v0
.end method

.method public getUserId()Ljava/lang/String;
    .locals 1

    .prologue
    .line 177
    sget-boolean v0, Lcom/burstly/lib/currency/CurrencyManager;->sIninialized:Z

    if-eqz v0, :cond_0

    .line 178
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    invoke-virtual {v0}, Lcom/burstly/lib/currency/AccountInfo;->getUserId()Ljava/lang/String;

    move-result-object v0

    .line 180
    :goto_0
    return-object v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public increaseBalance(ILjava/lang/String;)I
    .locals 2
    .parameter "amount"
    .parameter "currency"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;,
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    .line 233
    invoke-direct {p0}, Lcom/burstly/lib/currency/CurrencyManager;->checkInitialized()V

    .line 234
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->sAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    const/4 v1, 0x1

    invoke-direct {p0, v0, p1, p2, v1}, Lcom/burstly/lib/currency/CurrencyManager;->changeBalance(Lcom/burstly/lib/currency/AccountInfo;ILjava/lang/String;Z)I

    move-result v0

    return v0
.end method

.method public initManager(Landroid/content/Context;Ljava/lang/String;)V
    .locals 1
    .parameter "context"
    .parameter "publisherId"

    .prologue
    .line 86
    const/4 v0, 0x0

    invoke-virtual {p0, p1, p2, v0}, Lcom/burstly/lib/currency/CurrencyManager;->initManager(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V

    .line 87
    return-void
.end method

.method public initManager(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
    .locals 5
    .parameter "context"
    .parameter "publisherId"
    .parameter "userId"

    .prologue
    .line 98
    if-eqz p2, :cond_0

    invoke-virtual {p2}, Ljava/lang/String;->length()I

    move-result v0

    if-lez v0, :cond_0

    .line 99
    invoke-direct {p0, p1, p2, p3}, Lcom/burstly/lib/currency/CurrencyManager;->internalInitManager(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V

    .line 105
    :goto_0
    return-void

    .line 101
    :cond_0
    sget-object v0, Lcom/burstly/lib/currency/CurrencyManager;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "CurrencyManager"

    const-string v2, "Publisher or user id should be not null and should not be an empty string. Pulisher id : {0}!"

    const/4 v3, 0x2

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object p2, v3, v4

    const/4 v4, 0x1

    aput-object p3, v3, v4

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0
.end method

.method public removeAllCurrencyListeners()V
    .locals 1

    .prologue
    .line 166
    iget-object v0, p0, Lcom/burstly/lib/currency/CurrencyManager;->mListeners:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    .line 167
    return-void
.end method

.method public removeCurrencyListener(Lcom/burstly/lib/feature/currency/ICurrencyListener;)V
    .locals 1
    .parameter "listener"

    .prologue
    .line 156
    if-eqz p1, :cond_0

    .line 157
    iget-object v0, p0, Lcom/burstly/lib/currency/CurrencyManager;->mListeners:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->remove(Ljava/lang/Object;)Z

    .line 159
    :cond_0
    return-void
.end method
